Let {fn}n≥0 be a sequence of real numbers. Then the formal power series F(x)=∑n≥0fnxn is called the ordinary generating function of the sequence {fn}n≥0.
Let G(x)=∑n≥0anxn. Multiply both sides of the recurrence relation by xn+2, and sum over all natural numbers n, to get
n≥0∑an+2xn+2=3n≥0∑an+1xn+2−2n≥0∑anxn+2,
which is equivalent to
G(x)−x=3xG(x)−2x2G(x).
Expressing G(x), we get
G(x)=1−3x+2x2x.
The denominator of the right-hand side is again a quadratic polynomial. Note that 1−3x+2x2=(x−1)(2x−1). Therefore, we are going to find real numbers A and B so that
G(x)=1−3x+2x2x=x−1A+2x−1B.
After rearranging, we get
x=(2A+B)x−(A+B).
Two polynomials are the same if and only if their corresponding coefficients are the same. Therefore, it follows that 2A+B=1, and A+B=0. So A=1, and B=−1. Consequently,
G(x)=1−3x+2x2x=1−x−1+1−2x1.
Both terms on the right-hand side are very easy to expand now. So
Let {an}n≥0 and {bn}n≥0 be two sequences, and let A(x)=∑n≥0anxn, and B(x)=∑n≥0bnxn be their respective generating functions. Define cn=∑i=0naibn−i, and let C(x)=∑n≥0cnxn. Then
A(x)B(x)=C(x)
In other words, the coefficient of xn in A(x)B(x) is cn=∑i=0naibn−i.
When we multiply the infinite sum A(x)=a0+a1x+a2x2+⋯ and the sum B(x)=b0+b1x+b2x2+⋯, we multiply each term of the first sum by each term of the second sum, then add all these products. So a typical product is of the form aixi⋅bjxj. The exponent of x in this product will be n if and only if j=n−i, and the claim follows.
Theorem (The Product Formula)
Let an be the number of ways to build a certain structure on an n-element set, and let bn be the number of way to build another structure on an n-element set. Let cn be the number of ways to separate the set [n] into the intervals S={1,2,⋯,i} and T={i+1,i+2,⋯,n}, (the intervals S and T are allowed to be empty), and then to build a structure of the first kind on S, and a structure of the second kind on T. Let A(x),B(x), and C(x) be the respective generating functions of the sequences {an},{bn}, and {cn}. Then
There are ai ways to build a structure of the first kind on S, and bn−i ways to build a structure of the second kind on T. This is true for all i, as long as 0≤i≤n. Therefore, cn=∑i=0naibn−i, and our claim follows from the Lemma.
Same as the proof of the previous example, just here there is no limit on the size of the parts, and therefore, there are infinitely many parentheses on the right-hand side.
The crucial idea is this. It suffices to show that the generating functions of the two sequences are equal. It is clear that
F(x)=n≥0∑podd (n)xn=i≥1i idd ∏1−xi1
and
G(x)=n≥0∑pd(n)xn=i≥1∏(1+xi)=i≥1∏1−xi1−x2i.
Note that after cancellations, the denominator of G(x) will contain (1−xi) if and only if i is odd, and will therefore be the same as the denominator of F(x). As both numerators are equal to 1, the proof follows.
Let {fn}n≥0 be a sequence of real numbers. Then the formal power series F(x)=∑n≥0fnn!xn is called the exponential generating function of the sequence {fn}n≥0.
Let k be a fixed positive integer. Find the exponential generating function Sk(x)=∑n≥kS(n,k)xn/n ! of the Stirling numbers S(n,k) of the second kind.
To obtain a partition of [n] into k blocks, we need to partition [n] into k nonempty blocks, and then "do nothing" on each of those blocks. There is one way to do nothing on any nonempty block, therefore, each task has generating function
A(x)=k≥1∑k!xk=ex−1.
If the order of the blocks in a partition mattered, we could simply say that the generating function of the combined task is Ak(x) by the Product formula. However, the order of the blocks does not matter, therefore
Sk(x)=k!1(ex−1)k
We can now get an explicit formula for S(n,k) by computing the coefficient of xn/n ! in Sk(x).
A particularly useful property of exponential generating functions is that their derivatives are very easy to describe. Indeed, ((n+1)!xn+1)′=n!xn, and therefore
(n≥0∑ann!xn)′=n≥0∑an+1n!xn.
The following example makes good use of this observation.